package net.monare.mifss.admin.ui.comp;

import net.monare.mifss.MifssMessages;
import net.monare.mifss.admin.ui.win.ConfigureStorageWindow;
import net.monare.mifss.configurations.pojo.ApiKey;
import net.monare.mifss.evn.ConfigureSelectedApiKeyListener;

import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeButton;
import net.monare.mifss.evn.VerifyRemoveSelectedApiKeyListener;

public class ApiKeyUiLink extends HorizontalLayout {

	private static final long serialVersionUID = -6708281313702896356L;

	public static final String NAME_WIDTH = "220px";
	public static final String BUTTON_WIDTH = "80px";

	private Label apiNameLabel;
	private NativeButton configureApi;
    private NativeButton removeApiKey;

	public ApiKeyUiLink(ApiKey apiKey, ConfigureStorageWindow parent, String storageDefName) {

		apiNameLabel = new Label(apiKey.getName());
		apiNameLabel.setWidth(NAME_WIDTH);
		
		configureApi = new NativeButton(MifssMessages.getMessage("button.configure"));
		configureApi.setWidth(BUTTON_WIDTH);
		configureApi.addClickListener(new ConfigureSelectedApiKeyListener(parent, apiKey));

        removeApiKey = new NativeButton(MifssMessages.getMessage("button.remove"));
        removeApiKey.setWidth(BUTTON_WIDTH);
        removeApiKey.addClickListener(new VerifyRemoveSelectedApiKeyListener(parent, apiKey, storageDefName));

		addComponent(apiNameLabel);
		addComponent(configureApi);
        addComponent(removeApiKey);

	}
}
